package com.bzframework.web;

import com.bzframework.core.auth.Authorization;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Tag(name ="测试使用")
@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/response")
    @Operation(summary = "测试ResponseEntity返回")
    public ResponseEntity<String> test() {
        return ResponseEntity.ok("ok");
    }

    @GetMapping("/str")
    @Operation(summary = "测试字符串返回")
    public String testStr() {
        return "ok";
    }

    @GetMapping("/num")
    @Operation(summary = "测试数字返回")
    public Integer testNumber() {
        return 1;
    }

    @GetMapping("/mono")
    @Operation(summary = "测试mono返回")
    @Authorization(ignore = true)
    public Mono<String> testMono() {
        return Mono.just("mono response");
    }

    @GetMapping("/flux")
    @Operation(summary = "测试Flux返回")
    public Flux<Integer> testFlux() {
        return Flux.range(0, 10);
    }

    @GetMapping("/auth/no")
    @Operation(summary = "测试不需要校验权限")
    @Authorization(ignore = true)
    public Flux<Integer> testFluxNoAuth() {
        return Flux.range(0, 10);
    }


}
